<!DOCTYPE html>
<html lang="zh-CN" class="no-js">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width">
	<meta name="keywords" content="GitBlog,kts168的博客">
	<meta name="description" content="如果你自己拥有服务器或者云平台提供的云主机，我推荐你使用Linux+Nginx来运行GitBlog，如果你目前只有Apache环境也是可以的。">

	<!--[if lt IE 9]>
	<script src="/theme/default/js/html5.js"></script>
	<![endif]-->
	<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>
	
	<title>在Nginx上运行GitBlog|kts168的博客</title>
	
	<link rel="stylesheet" href="/theme/default/css/genericons.css?ver=2.2" type="text/css" media="all" />
	<link rel="stylesheet" href="/theme/default/css/style.css?ver=2.2" type="text/css" media="all" />
	<link rel="stylesheet" href="/theme/default/css/markdown.css?ver=2.2" type="text/css" media="all" />
	<link rel="alternate" type="application/rss+xml" title="kts168的博客" href="/feed.xml" />
	<!--[if lt IE 9]>
	<link rel="stylesheet" href="/theme/default/css/ie.css?ver=2.2" type="text/css" media="all" />
	<![endif]-->
	<!--[if lt IE 8]>
	<link rel="stylesheet" href="/theme/default/css/ie7.css?ver=2.2" type="text/css" media="all" />
	<![endif]-->
	
	<script type="text/javascript" src="/theme/default/js/jquery/jquery.js?ver=2.2"></script>
	<script type="text/javascript" src="/theme/default/js/jquery/jquery-migrate.min.js?ver=2.2"></script>
	
	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "//hm.baidu.com/hm.js?732acc76ff6bd41343951a67cbfafe30";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>
	
</head>

<body>
<div id="page" class="hfeed site">
	<a class="skip-link screen-reader-text" href="#content">Skip to content</a>
	
	    <div id="sidebar" class="sidebar">
	<header id="masthead" class="site-header" role="banner">
		<div class="site-branding">
			<h1 class="site-title"><a href="/" rel="home">kts168的博客</a></h1>
				<p class="site-description">自豪地采用GitBlog</p>
				<button class="secondary-toggle">菜单和挂件</button>
		</div><!-- .site-branding -->
	</header><!-- .site-header -->
	<div id="secondary" class="secondary">
		<div id="widget-area" class="widget-area" role="complementary">
		
			<aside id="categories" class="widget widget_categories">
    <h2 class="widget-title">分类目录</h2>
    <ul>
                <li class="cat-item"><a href="/category/GitBlog.html" >GitBlog</a></li>
            </ul>
</aside>
		    <aside class="widget widget_archive">
    <h2 class="widget-title">文章归档</h2>
    <ul>
        <li><a href="/archive/201507.html">2015-07</a></li>
        </ul>
</aside>
		    <aside id="recent-posts" class="widget widget_recent_entries">
    <h2 class="widget-title">近期文章</h2>
    <ul>
        <li><a href="/blog/install.html">GitBlog安装</a></li>
        <li><a href="/blog/struct.html">GitBlog目录结构</a></li>
        <li><a href="/blog/config.html">GitBlog配置</a></li>
        <li><a href="/blog/edit.html">编写GitBlog博客</a></li>
        <li><a href="/blog/other-func.html">GitBlog评论，订阅，统计等功能</a></li>
        </ul>
</aside>
		    <aside id="tag_cloud" class="widget widget_tag_cloud">
    <h2 class="widget-title">标签</h2>
    <div class="tagcloud">
        <a href="/tags/GitBlog.html" title="GitBlog" >GitBlog</a>
        </div>
</aside>
		    <aside id="text" class="widget widget_text">
    <h2 class="widget-title">简介</h2>	
    <div class="textwidget">
    	<p>GitBlog是一个简单易用的Markdown博客系统，这是我的第一个GitBlog博客</p>
    </div>
</aside>
	    </div><!-- .widget-area -->
    </div><!-- .secondary -->
</div><!-- .sidebar -->  
	    <div id="content" class="site-content">
    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">
        
            <article class="post hentry">
<header class="entry-header">
    <h1 class="entry-title">在Nginx上运行GitBlog</h1>
</header><!-- .entry-header -->
<div class="entry-content">
<!--
author: jockchou
date: 2015-07-22
title: 在Nginx上运行GitBlog
tags: GitBlog
category: GitBlog
status: publish
summary: 如果你自己拥有服务器或者云平台提供的云主机，我推荐你使用Linux+[Nginx](http://nginx.org/)来运行GitBlog，如果你目前只有Apache环境也是可以的。
-->
<p>如果你自己拥有服务器或者云平台提供的云主机，我推荐你使用Linux+<a href="http://nginx.org/">Nginx</a>来运行GitBlog，如果你目前只有Apache环境也是可以的。</p>
<h2>域名解析</h2>
<p>将你准备好的域名解析到你的主机IP，推荐使用<a href="https://www.dnspod.cn/">dnspod</a>来管理和监控你的域名，具体的使用方法参考dnspod官方说明文档，非常简单。</p>
<h2>Nginx+PHP运行环境</h2>
<p>首先安装好你的Nginx和PHP环境，PHP版本要求5.3以上。如果你没有安装过，可Google搜索相关教程，也可以参照Nginx和PHP官方的文档。这是第一步，有一个正常的Nginx + PHP的运行环境。</p>
<h2>配置Nginx</h2>
<p>nginx可参考如下配置：</p>
<pre><code>server {
        listen       80;
        server_name  jockchou.gitblog.cn;
        root         /data/vhosts/jockchou.gitblog.cn;
        index        index.html index.htm index.php;

        location ~ \.(jpg|png|gif|js|css|swf|flv|ico)$ {
                 expires 12h;
        }

        location / {
                if (!-e $request_filename) {
                    rewrite ^(.*)$ /index.php?$1 last ;
                    break;
                }
        }

        location ~* ^/(doc|logs|app|sys)/ {
                return 403;
        }

        location ~ .*\.(php|php5)?$
        {
                fastcgi_connect_timeout 300;
                fastcgi_send_timeout 300;
                fastcgi_read_timeout 300;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include        fastcgi_params;
        }
}</code></pre>
<p>将以上配置中的server_name和root改成你自己的，fastcgi_pass配成你的CGI进程端口。</p>
<h2>权限配置</h2>
<p>由于GitBlog的缓存机制需要写<code>app/cache</code>目录，必要时请查看并修改这个目录的权限，以确保你的PHP拥有写这个目录的权限。通常你只需要将此目录的所属者和组修改成CGI的运行账户。</p>
<h2>运行</h2>
<p>以上配置好以后，启动你的Nginx和CGI服务，上传GitBlog源代码到网站目录，通过浏览器访问解析到本机的域名观察页面效果。如果页面没有正常显示，通过错误码来检查你的CGI和Nginx配置。</p>
</div><!-- .entry-content --><footer class="entry-footer">
	    <span class="posted-on">
        <span class="screen-reader-text">Posted on </span>
        <time class="entry-date published">2015-07-22</time>
    </span>
		
	    <span class="byline">
        <span class="author vcard">
            <span class="screen-reader-text">Author </span>
            jockchou
        </span>
    </span>
        
        <span class="cat-links">
        <span class="screen-reader-text">Categories </span>
          
           <a href="/category/GitBlog.html" rel="category">GitBlog</a>
            </span>
        
    
        <span class="tags-links">
    	
        <span class="screen-reader-text">Tags </span>
          
           <a href="/tags/GitBlog.html" rel="tag">GitBlog</a>
            </span>
    </footer><!-- .entry-footer --></article><!-- #post-## -->            <div id="comments" class="comments-area">
	<div id="respond" class="comment-respond">
		<div id="disqus_thread"></div>
		<script>
		   var disqus_config = function () {
		   this.page.url = location.href;
		   this.page.identifier = '65a71eaf0ba3a72606874bc322eda156';
		   };
		(function() {
			var d = document, s = d.createElement('script');
			s.src = '//demo-site.disqus.com/embed.js';
			s.setAttribute('data-timestamp', +new Date());
			(d.head || d.body).appendChild(s);
		})();
		</script>
		<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
	</div><!-- #respond -->
</div><!-- .comments-area -->
            
        </main><!-- .site-main -->
    </div><!-- .content-area -->
</div><!-- .site-content -->	    <footer id="colophon" class="site-footer" role="contentinfo">
    <div class="site-info">
        <!--<a href="https://github.com/jockchou/gitblog">Proudly powered by Gitblog</a>-->
    </div><!-- .site-info -->
</footer><!-- .site-footer -->
	
</div><!-- .site -->
<script type="text/javascript" src="/theme/default/js/skip-link-focus-fix.js?ver=2.2"></script>
<script type="text/javascript">
/* <![CDATA[ */
var screenReaderText = {"expand":"<span class=\"screen-reader-text\">\u5c55\u5f00\u5b50\u83dc\u5355<\/span>","collapse":"<span class=\"screen-reader-text\">\u6298\u53e0\u5b50\u83dc\u5355<\/span>"};
/* ]]> */
</script>
<script type="text/javascript" src="/theme/default/js/functions.js?ver=2.2"></script>

<link rel="stylesheet" href="//cdn.bootcss.com/highlight.js/8.6/styles/github.min.css">
<script src="//cdn.bootcss.com/highlight.js/8.6/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script>
<script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.5.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

</body>
</html>
